const mapsConfig = {
  // 高德Map配置
  AMAP: {
    // start webserve api
    serveUrl: 'https://restapi.amap.com/v3/geocode/regeo',
    serveimgUrl: 'https://restapi.amap.com/v3/staticmap',
    serveParams: {
      location: '', // lat<纬度>,lng<经度>
      key: '3d8596c3878acc9e7021a689a9d2990f',
      output: 'json',
    },
    // end

    // start JS API
    webKey: 'ede8cf1c9d9826f036f078c85e0d519f',
    securityJsCode: '78818effb3249d0dcf3dc4ca4f124f5d',
    // end
  },

  // 百度Map配置
  BMAP: {
    // start webserve api
    serveUrl: 'https://api.map.baidu.com/reverse_geocoding/v3/',
    serveimgUrl: 'https://api.map.baidu.com/staticimage/v2',
    serveParams: {
      location: '', // lat<纬度>,lng<经度>
      ak: 'lEYEdbMqN4Qvo6BkQFK4GgodU387hLQ8',
      coordtype: 'wgs84',
      output: 'json',
    },
    // end

    // start JS API
    webKey: 'PJvmqP1ZqUSWsTXW7kzqFAdOw2Ozbpis',
    // end
  },

  // 腾讯Map配置
  QMAP: {
    // start webserve api
    serveUrl: 'https://apis.map.qq.com/ws/geocoder/v1/',
    serveimgUrl: 'https://apis.map.qq.com/ws/staticmap/v2/',
    serveParams: {
      location: '', // lat<纬度>,lng<经度>
      key: 'RWRBZ-TKIKS-MPKOF-6DSR2-JUZN2-MYBFW',
      output: 'json',
    },
    // end
  },
}

function getCurMapConfig(map) {
  const key = Object.keys(mapsConfig).find((item) => item === map) || 'BMAP'

  return {
    name: 'MAP-Config',
    config(config) {
      return {
        define: {
          MAP: { Channel: key, KEY: mapsConfig[key].serveParams.ak || mapsConfig[key].serveParams.key, ...mapsConfig[key] },
        },
      }
    },
  }
}

export default getCurMapConfig
